#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#ifdef  _WIN64
#pragma warning (disable:4996)
#endif



#if defined(WIN32)
# include <windows.h>
# include <conio.h>
#else
# include "conio.h"
# include <stdlib.h>
# include <ctype.h>
# include <string.h>
#endif

#include <HD/hd.h>
#include <HDU/hduError.h>
#include <HDU/hduVector.h>
#include "qcustomplot.h"
#include <QDateTime>
#include <QTimer>
#include <QVector>
#include <QLabel>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
     void saveSensorData();

private:
    Ui::MainWindow *ui;
    // 触觉设备句柄
    HHD hHD;
    // 调度器回调句柄
    HDSchedulerHandle gCallbackHandle;
    // 当前弹簧刚度
    HDdouble gSpringStiffness;
    QCustomPlot *plotX;
    QCustomPlot *plotY;
    QCustomPlot *plotZ;
    QTimer *timer;
    QDateTime startTime;
    QVector<double> times;
    QVector<double> valuesX;
    QVector<double> valuesY;
    QVector<double> valuesZ;
    QVector<double> allTimes;
    QVector<double> allValuesX;
    QVector<double> allValuesY;
    QVector<double> allValuesZ;
    const int MAX_DISPLAY_TIME = 5;
    QLabel *labelX;
    QLabel *labelY;
    QLabel *labelZ;
    QLabel *coordXLabel;
    QLabel *coordYLabel;
    QLabel *coordZLabel;
    QFont font;


    void updatePlot(const hduVector3Dd& position, const hduVector3Dd& JointEncoders, const hduVector3Dd& GimbalEncoders,const hduVector3Dd& force);
};

#endif // MAINWINDOW_H
